import type {TableProps} from "./table.types";
import type {MetaView} from "../ui.types";
import type {Component} from "vue";

export type SortableCallbackFn = (newIndex: number, oldIndex: number) => void


export type MTableButton = {
    size?: 'large' | 'default' | 'small',
    handler?: (row: any, event?: Event) => void,
    title?: string | Function,
    type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | Function,
    link?: boolean | Function,
    plain?: boolean | Function,
    text?: boolean | Function,
    round?: boolean | Function,
    circle?: boolean | Function,
    disabled?: boolean | Function,
    dark?: boolean | Function,
    color?: string | Function,
    tag?: string | Function,
}

export type MTableColumn = {
    label: string
    component: Component,
    width?: string | number,
}


export type MorghulisTableProps = TableProps & {
    loading?: boolean,
    view: MetaView,
    buttons?: MTableButton[],
    columns?: MTableColumn[],
    sortableCallback?: SortableCallbackFn
}


export const morghulisTablePropsDefaults = {
    border: true,
    fit: true,
    showHeader: true,
    highlightCurrentRow: false,
    headerCellClassName: 'm-table-header-cell',
    showOverflowTooltip: true,

    // currentRowKey: 'id',
    // rowKey: 'id'
}